home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group97b.txt / 000092_icon-group-sender _Thu Oct 23 17:59:19 1997.msg < prev    next >
Internet Message Format  |  2000-09-20  |  2KB

  1. Return-Path: <icon-group-sender>
  2. Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
  3.     by cheltenham.cs.arizona.edu (8.8.7/8.8.7) with SMTP id RAA09006
  4.     for <icon-group-addresses@cheltenham.CS.Arizona.EDU>; Thu, 23 Oct 1997 17:59:18 -0700 (MST)
  5. Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
  6.     id AA23922; Thu, 23 Oct 1997 17:59:18 -0700
  7. From: gep2@computek.net
  8. Date: Thu, 23 Oct 1997 18:08:20 -0500
  9. Message-Id: <199710232308.SAA04895@axp.cmpu.net>
  10. Mime-Version: 1.0
  11. Content-Type: text/plain
  12. Content-Transfer-Encoding: 7bit
  13. Subject: tabulating values
  14. To: icon-group@cs.arizona.edu
  15. X-Mailer: SPRY Mail Version: 04.00.06.17
  16. Errors-To: icon-group-errors@cs.arizona.edu
  17. Status: RO
  18.  
  19. >Hello.  I am trying to write up a program that takes a list of values and
  20. counts their frequency of occurence (like a word count, but with
  21. numbers).  (I'll eventually make a histogram out of the results.)  For
  22. example, given the following output
  23. 1
  24. 2
  25. 1
  26. 3
  27. 10
  28. 100
  29. I'd like the following output
  30. value    n
  31. 1        2
  32. 2        1
  33. 3        1
  34. 10       1
  35. 100      1
  36.  
  37. In fact, it's EXACTLY a "word" count... since a "word" can be made up of numeric 
  38. characters just as well as alphabetic ones!  Surely there are word count 
  39. programs already in the library.
  40.  
  41. The only thing that might be different would come when it's time to do the sort 
  42. for the output, so you get them in the order you indicated and not in 
  43. string-sort order (1,10,100,2,3...) but you can probably get that by just 
  44. ensuring that you convert the values to numeric before storing them in your 
  45. table (in SNOBOL4, and probably in ICON, you convert a numeric string variable 
  46. value to a number by simply adding a unary "+" on the front of the variable 
  47. name...)
  48.  
  49. If there's not something in the library to do this, it's because the job is _so_ 
  50. trivial that there's little reason to do a library routine for it...
  51.  
  52. Gordon Peterson
  53. http://www.computek.net/public/gep2/
  54. Support the Anti-SPAM Amendment!  Join at http://www.cauce.org/
  55.  
  56.